package com.tongjie.hotelbooking.im.message.entiry;

import com.tongjie.hotelbooking.im.conversation.entiry.Conversation;
import com.tongjie.hotelbooking.user.entity.User;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "hb_im_message")
public class ImMessage implements Serializable {

    private static final long serialVersionUID = 2276885176280693560L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "conversation_id")
    private Conversation conversation;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "sender_user_id")
    private User senderUser;

    @Column
    @Temporal(TemporalType.TIMESTAMP)
    private Date sendTime;

    @Column
    @Enumerated(EnumType.STRING)
    private MessageType messageType;

    @Column
    private String textMessage;

    @Column(length = 1000)
    private String html;

    @Column
    private String imageUrl;

}
